WPF and Silverlight Edition Basic Library > TabControl > TabControl Features > Tab Closing |
By default, users can't close the tabs on a C1TabControl control. You can add a close button to each tab by setting the TabItemClose property to InEachTab. This will allow users to close any tab in the control. On-tab close buttons appear as follows:
If you prefer, you can create a global close button that will appear on the tabstrip instead of directly on the tabs. To add the global close button, you set the TabItemClose property to GlobalClose. Clicking the global close button will close the currently selected tab. The global close button appears as follows:
To allow users to close tabs, follow one of the following methods:
To allow users to close tabs using a universal button, add TabItemClose="GlobalClose" to <c1:C1TabControl> tab so that the markup resembles the following:
XAML |
Copy Code
|
---|---|
<c1:C1TabControl TabItemClose="GlobalClose"></c1:C1TabControl>
|
Complete the following steps:
Visual Basic Copy Code C1TabControl1.TabItemClose = GlobalClose
C# Copy Code c1TabControl1.TabItemClose = GlobalClose;
Complete the following steps:
To prevent a user from closing a particular tab, use one of the following methods:
To prevent a user from closing a tab, add CanUserClose="False" to the <c1:C1TabItem> tag of the tab you want to prevent users from closing. The XAML will resemble the following:
XAML |
Copy Code
|
---|---|
<c1:C1TabItem CanUserClose="False"></c1:C1TabControl>
|
Complete the following steps:
Visual Basic Copy Code C1TabItem1.CanUserClose = False
C# Copy Codec1TabItem1.CanUserClose = false;
Complete the following steps: